package com.feicheng.lanniao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.feicheng.lanniao.entity.CarImage;
import com.feicheng.lanniao.entity.HouseImage;
import com.feicheng.lanniao.mapper.HouseImageMapper;
import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.HouseImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author tianchunlei
 * @Des //房屋小图业务类
 * @Date 2021/9/27
 **/
@Service
public class HouseImageServiceImpl extends ServiceImpl<HouseImageMapper,HouseImage> implements HouseImageService {

    @Resource
    private HouseImageMapper houseImageMapper;

    @Autowired
    private HouseImageService houseImageService;

    /**
     * @Author tianchunlei
     * @Description //批量插入房屋图片小图
     * @Date 2021/9/27 10:18
     * @Param list
     * @return
     */
    @Override
    public ResultInfo batchAdd(List<HouseImage> list) {
        houseImageService.saveBatch(list);
        return ResultInfo.success();
    }

    /**
     * @Author tianchunlei
     * @Description //按照房屋id批量删除房屋小图
     * @Date 2021/9/27 10:19
     * @Param houseId
     * @return
     */
    @Override
    public ResultInfo batchDelete(Integer houseId) {
        houseImageMapper.deleteImageUrls(houseId);
        return ResultInfo.success();
    }

    /**
     * @Author tianchunlei
     * @Description //按照房屋id查询图房屋小图地址列表
     * @Date 2021/9/27 10:19
     * @Param houseId
     * @return
     */
    @Override
    public ResultInfo selectUrlAll(Integer houseId) {
        QueryWrapper<HouseImage> queryWrapper = new QueryWrapper<HouseImage>();
        queryWrapper.eq("house_id",houseId);
        return ResultInfo.success(houseImageMapper.selectList(queryWrapper));
    }
}
